import React, { Component, ReactComponentElement } from 'react';
import { createModal, show, close } from './createModal';

// eslint-disable-next-line @typescript-eslint/no-explicit-any
export default function(App: any) {
  return class Page extends Component<ReactComponentElement<T, P>> {
    public state = {
      modal: {},
    };

    public modal = {
      createModal: createModal.bind(this),
      show: show.bind(this),
      close: close.bind(this),
    };

    public outPut = {
      modal: this.modal,
    };

    deleteModal = (id: string) => {
      const { modal } = this.state;
      delete modal[id];
      this.setState({
        modal,
      });
    };

    render() {
      return <App {...this.props} {...this.outPut} />;
    }
  };
}
